import { Input } from 'antd'
import { useEffect, useState } from 'react'

const InputTextChangeByBlur = ({
  value,
  onChange,
  ...props
}) => {

  const [inputValue, setInputValue] = useState()

  useEffect(() => {
    setInputValue(value)
  }, [value])

  return <Input
    autoComplete="off"
    {...props}
    value={inputValue}
    onChange={(e) => { setInputValue(e.target.value) }}
    onBlur={() => { onChange(inputValue) }}
  ></Input>
}

export default InputTextChangeByBlur